import { ref } from 'vue'
import emitter from '@/render/utils/mitt'

// type CallbackFn = (item?: any) => void

export function usePageDialogFormTree(formData: any) {
  const dialogVisible = ref(false)
  const newFormItem = ref({})

  const openDialog = (item: any) => {
    dialogVisible.value = true
    newFormItem.value = item.data
  }
  const closeDialog = () => {
    dialogVisible.value = false
  }

  const handleConfirm = () => {
    dialogVisible.value = false
    emitter.emit('update', 'emitter')
  }

  return { dialogVisible, newFormItem, openDialog, closeDialog, handleConfirm }
}
